class Solution(object):
    def maxScoreSightseeingPair(self, values):
        max_len = values[0] + values[1] - 1
        max_c = max(values[0] - 1, values[1])
        for num in values[2:]:
            max_c -= 1
            max_len = max(max_len, max_c + num)
            max_c = max(max_c, num)
        return max_len


data = Solution()
values = [8, 1, 5, 2, 6]
print(data.maxScoreSightseeingPair(values))
